﻿using Beetle;
using Smark.Core;
using System;
using System.IO;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;

internal class Class_f
{
    public bool _field_a;
    public string _field_b;
    public string _field_c;
    public int _field_d;
    public DateTime _field_e;
    private static Class_ae _field_f = null;
    private static object _field_g = null;
    private static string _field_h;
    private static string _field_i;
    private static char[] _field_j = new char[] { '\r', '\n' };

    public static Class_ae f()
    {
        lock (typeof(Class_ae))
        {
            if (_field_f == null)
            {
                _field_f = new Class_ae();
                try
                {
                    foreach (MethodInfo info in typeof(Class_ab).GetMethods(BindingFlags.Public | BindingFlags.Static))
                    {
                        if (info.GetCustomAttributes(typeof(Class_c), false).Length > 0)
                        {
                            _field_g = info.Invoke(null, null);
                        }
                    }
                    foreach (FieldInfo info2 in typeof(Class_ah).GetFields(BindingFlags.Public | BindingFlags.Static))
                    {
                        if (info2.GetCustomAttributes(typeof(Class_t), false).Length > 0)
                        {
                            _field_h = (string) info2.GetValue(null);
                        }
                    }
                    foreach (FieldInfo info3 in typeof(Class_ah).GetFields(BindingFlags.Public | BindingFlags.Static))
                    {
                        if (info3.GetCustomAttributes(typeof(Class_b), false).Length > 0)
                        {
                            _field_i = (string) info3.GetValue(null);
                        }
                    }
                    ((RSACryptoServiceProvider) _field_g).FromXmlString(f(_field_i));
                    using (StreamReader reader = new StreamReader(TcpUtils.g() + f(_field_h)))
                    {
                        string[] strArray = reader.ReadToEnd().Split(_field_j, StringSplitOptions.RemoveEmptyEntries);
                        if (f(strArray[0], strArray[1]))
                        {
                            string[] strArray2 = Encoding.UTF8.GetString(Convert.FromBase64String(strArray[0])).Split(new char[] { ';' });
                            _field_f._field_b = strArray2[0];
                            _field_f._field_c = strArray2[1];
                            _field_f._field_d = int.Parse(strArray2[2]);
                            _field_f._field_e = new DateTime(long.Parse(strArray2[3]));
                            _field_f._field_a = _field_f._field_e > DateTime.Now;
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
        }
        return _field_f;
    }

    public static byte[] f(byte[] A_0)
    {
        return ((RSACryptoServiceProvider) _field_g).Decrypt(A_0, false);
    }

    public bool f(int A_0)
    {
        return (this._field_a && (A_0 <= this._field_d));
    }

    internal static string f(string A_0)
    {
        DESCrypto crypto = new DESCrypto();
        DESCrypto.DESInfo info = new DESCrypto.DESInfo {
            IV = Convert.FromBase64String(TcpServer._field_g),
            Key = Convert.FromBase64String(TcpChannel._field_k)
        };
        crypto.KeyInfo = info;
        return crypto.Decrypt(A_0);
    }

    public static bool f(byte[] A_0, byte[] A_1)
    {
        return ((RSACryptoServiceProvider) _field_g).VerifyData(A_0, "MD5", A_1);
    }

    public static bool f(string A_0, string A_1)
    {
        return f(Encoding.UTF8.GetBytes(A_0), Convert.FromBase64String(A_1));
    }

    public static string g(string A_0)
    {
        return Encoding.UTF8.GetString(f(Convert.FromBase64String(A_0)));
    }
}

